# Importing Data
BELGIUM <- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Steel/TSA.xlsx",sheet = "Sheet1", range = "E1:E239")

# Checking the Imported Data
View(BELGIUM)
# Creating Time Series Data
BELGIUM_ts <- ts(BELGIUM, start=c(2000,1), end=c(2019,09), frequency=12)
# Viewing and Checking the Created Time Series Data
BELGIUM_ts
sum(is.na(BELGIUM_ts))
library(forecast)
BELGIUM_ts <- tsclean(BELGIUM_ts)
BELGIUM_ts

# Identification: Plotting the Time Series Data
plot(BELGIUM_ts)

# Estimating the appropriate model
BELGIUM_ts_model <- auto.arima(BELGIUM_ts)
BELGIUM_ts_model

# Forecasting
options(max.print=1000000)
BELGIUM_ts_forecast <- forecast (BELGIUM_ts_model, level=c(95), h=255)
plot(BELGIUM_ts_forecast)
BELGIUM_ts_forecast             

# Exporting
write.table(BELGIUM_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Steel/BELGIUM_TSA.csv", sep=",")
